{% extends 'live/live_base.html' %}

{% block title %}
    直播
{% endblock %}

{% block content %}
    <div class="container-fluid">
        <div class="row justify-content-between">
            <div class="col-auto">
                {#   标签#}
                <div class="row">
                    <div class="col-auto">
                        <h4>全部直播</h4>
                    </div>
                    <div class="col-auto">
                        <a type="button"
                           class="btn {% if not type %} btn-outline-primary{% else %}btn-outline-secondary{% endif %}"
                           style="border-radius: 30px"
                           href="{% url 'all_live' %}">全部</a>
                    </div>
                    {% for label in all_flabel %}
                        <div class="col-auto">
                            <a type="button"
                               class="btn {% if type == label.id %} btn-outline-primary{% else %} btn-outline-secondary{% endif %}"
                               style="border-radius: 30px; margin-bottom: 10px"
                               href="{% url 'all_live' %}?type={{ label.id }}">{{ label.name }}</a>
                        </div>
                    {% endfor %}
                </div>
            </div>
        </div>
    </div>

    <hr>
    <div class="container-fluid">
        {#       子标签#}
        <div class="row">
            {% for label in son_label %}
                <div class="col-auto">
                    <a type="button" class="btn {% if son_type == label.id %}btn-outline-primary{% else %} btn-outline-secondary{% endif %}" style="border-radius: 30px;margin-bottom: 10px"
                       href="{% url 'son_live' %}?type={{ label.father_label.id }}&son_type={{ label.id }}">{{ label.name }}</a>
                </div>
            {% endfor %}
        </div>
        <br>
        {#  全部直播 #}
        <div class="row justify-content-center">
            {% for live in all_live.object_list %}
                <div class="col-auto" style="padding-bottom: 10px; width: 300px">
                    <div class="card" style="width: 270px;">
                        <a href="#">
                            <img src="{{ MEDIA_URL }}{{ live.image }}" class="card-img-top" alt="..."
                                 style="width: 270px;height: 168px;max-width: 100%;">
                        </a>
                        <div class="card-body">
                            <div class="row">
                                <div class="col-8">
                                    <p class="card-text" style="font-weight: bold">
                                        <a href="#" style="color: black">
                                            <span class="d-inline-block text-truncate"
                                                  style="max-width: 150px;">
                                            {{ live.name }}</span>
                                        </a>
                                    </p>
                                </div>
                                <div class="col-4  align-self-center text-right">
                                    <p class="card-text" style="font-size: 10px">
                                        <a href="#" class="text-secondary">
                                            <span class="d-inline-block text-truncate"
                                                  style="max-width: 150px;">
                                        {{ live.label }}</span>
                                        </a>
                                    </p>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-8 align-self-center">
                                    <p class="card-text" style="font-size: 10px"><a
                                            href="{% url 'detail_user' %}?username={{ live.user.username }}"
                                            target="_blank"
                                            style="text-decoration: none"
                                            class="text-secondary">{{ live.user }}</a>
                                    </p>
                                </div>
                                <div class="col-4 text-right">
                                    <p class="card-text text-secondary" style="font-size: 10px">
                                        <i class="bi bi-people"></i> &nbsp; {{ live.hot_num }}
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            {% endfor %}
        </div>
    </div>



    {#    分页#}
    <div class="row justify-content-center">
        <div class="col-auto" style="margin-top: 50px">
            <nav aria-label="Page navigation example">
                <ul class="pagination" style="right:500px">
                    {% if all_live.has_previous %}
                        <li class="page-item">
                            <a href="?{{ all_live.previous_page_number.querystring }}"
                               class="page-link" aria-label="Previous">
                                上一页
                            </a>
                        </li>
                    {% endif %}
                    {% for page in all_live.pages %}
                        {% if page %}
                            {% ifequal page all_live.number %}
                                <li class="page-item">
                                    <a class="page-link" href="?{{ page.querystring }}">{{ page }}</a>
                                </li>
                            {% else %}
                                <li>
                                    <a class="page-link page" href="?{{ page.querystring }}">{{ page }}</a>
                                </li>
                            {% endifequal %}
                        {% else %}
                            <li class="none">...</li>
                        {% endif %}
                    {% endfor %}
                    {% if all_live.has_next %}
                        <li class="page-item">
                            <a href="?{{ all_live.next_page_number.querystring }}" class="page-link"
                               aria-label="Next">下一页</a>
                        </li>
                    {% endif %}
                </ul>
            </nav>
        </div>
    </div>
{% endblock %}

